package de.pcsoft.framework.jclr;

/**
 * User: Christoph
 * Date: 15.06.12
 * Time: 17:08
 */
class JCLRHelpUtils {

    static String buildMainHelp(GroupDefinitionType groupDefinitionType, SettingsType settingsType) {
        StringBuilder sb = new StringBuilder();

        sb.append(buildMainSyntaxString(groupDefinitionType, settingsType));
        sb.append("\n\n");
        sb.append(buildMainHelpString(groupDefinitionType, settingsType));
        sb.append("\n\n");
        if (settingsType.getHelpSettings().getExamples() != null) {
            sb.append(buildMainExampleString(settingsType.getHelpSettings().getExamples()));
            sb.append("\n\n");
        }

        return sb.toString();
    }

    private static String buildMainSyntaxString(GroupDefinitionType groupDefinitionType, SettingsType settingsType) {
        StringBuilder sb = new StringBuilder();

        sb.append(settingsType.getApplicationFile());
        sb.append(" ");

        for (ArgumentType argumentType : groupDefinitionType.getSimpleArgumentAndValueArgumentAndStringArgument()) {
            if (argumentType instanceof StringArgumentType) {
                sb.append("<").append(argumentType.getKey()).append(">");
            } else if (argumentType instanceof SimpleArgumentType) {
                sb.append(((SimpleArgumentType) argumentType).getShortArg())
            }
        }

        return sb.toString();
    }

    private static String buildMainHelpString(GroupDefinitionType groupDefinitionType, SettingsType settingsType) {
        StringBuilder sb = new StringBuilder();


        return sb.toString();
    }

    private static String buildMainExampleString(HelpSettingsType.Examples examples) {
        StringBuilder sb = new StringBuilder();

        for (String example : examples.getExample()) {
            sb.append(example);
            sb.append("\n");
        }

        return sb.toString();
    }

}
